<template>
  <div class="about">
    <p>账号：<input v-model="obj.username"></p>
    <p>密码：<input v-model="obj.password"></p>
    <button @click="submit" class="btn">提交</button>
  </div>
</template>
<script>
import axios from 'axios';
// axios 二次封装是为了干什么？
import { postLogin } from '../api/index'
export default {
  data() {
    return {
      obj: {
        username: '',
        password: ''
      }
    }
  },
  methods: {
    submit() {
      postLogin({...this.obj}).then(res => {
        // 登陆之后存储token
        sessionStorage.setItem('token', res.data.token)
      })
    }
  }
}
</script>
<style lang="scss">
  .btn {
    height: 35px;
    border-radius: 4px;
    padding: 5px;
    cursor: pointer;
    background: #ccc;
    user-select: none;
  }
</style>
